//
//  LogisticsListInFoViewController.m
//  DA_V
//
//  Created by 中亿世联前台 on 15/5/29.
//  Copyright (c) 2015年 zhouhai. All rights reserved.
//

#import "LogisticsListInFoViewController.h"
#import "InterFace.h"
#import "UIViewAdditions.h"
#import "WuLiuTableViewCell.h"
#import "WuLiuTableHeadView.h"
#import "LogisticsModel.h"
#import "GMDCircleLoader.h"

@interface LogisticsListInFoViewController ()<UITableViewDataSource,UITableViewDelegate,LogisticsModelDelegate>

@property (nonatomic,strong)NSMutableArray *wuliuListArr;
@end

@implementation LogisticsListInFoViewController
@synthesize ExpressBillID;
- (instancetype)init{

    self = [super init];
    if (self) {
        self.wuliuListArr = [NSMutableArray array];
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [self colorWithHexString:@"#F5F5F5"];
    [self initNav];
    navTitle.text = @"物流费－清单详情";
    
    LogisticsModel *logisModel = [[LogisticsModel alloc] init];
    logisModel.logisticsModelDelegate = self;
  
    NSString *agentId = [[NSUserDefaults standardUserDefaults] objectForKey:@"userID"];
    NSDictionary *dic =@{@"AgentID":agentId,@"ExpressBillID":self.ExpressBillID};
    [logisModel getWuliuList:self.wuliuListArr parameter:dic];
    
    [self createTable];
      [GMDCircleLoader setOnView:self.view withTitle:@"加载中···" animated:YES];
}

#pragma -mark  //获取物流费－清单详情接口结束
- (void)getWuLiuListEnd{
[GMDCircleLoader hideFromView:self.view animated:YES];
    [self.tableView reloadData];
    NSLog(@"请求完返回结果=== %@",self.wuliuListArr);
}
#pragma -mark //网络异常代理
- (void)requesterror{
    [GMDCircleLoader hideFromView:self.view animated:YES];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"网络异常" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    [alert show];
}
#pragma -mark ;//请求服务器繁华的错误信息代理
- (void)getrequesterror:(NSString *)error{
    [GMDCircleLoader hideFromView:self.view animated:YES];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:error delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    [alert show];
}
#pragma -mark 创建tableView 的HeadViwe
-(UIView *)createTableViewHeadView{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 70)];
    view.backgroundColor = [UIColor whiteColor];
    WuLiuTableHeadView *tableViweHead = [[[NSBundle mainBundle] loadNibNamed:@"GeRen_xibs" owner:self options:nil] objectAtIndex:12];
    tableViweHead.frame = CGRectMake(10, 0, SCREEN_WIDTH-20, 70);
//    @property (weak, nonatomic) IBOutlet UILabel *time;//时间
//    
//    @property (weak, nonatomic) IBOutlet UILabel *prace;//钱钱
    tableViweHead.time.text = self.time;
    tableViweHead.prace.text = [NSString stringWithFormat:@"¥%@",self.wuliuPrace];
    [view addSubview:tableViweHead];
    
    return view;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return self.wuliuListArr.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return 59;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *wuliuindert = @"wuliu";
    WuLiuTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:wuliuindert];
    if (cell == nil) {
        cell = [[WuLiuTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:wuliuindert];
    }
    LogisticsModel *model = self.wuliuListArr[indexPath.row];
    [cell showWUliuViewData:model];
    return cell;
}


#pragma -mark 创建tableView

-(void)createTable{

    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, navView.bottom, SCREEN_WIDTH, SCREEN_HEIGHT-64-50)];
    self.tableView.backgroundColor = LineColor;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.tableView];
    self.tableView.tableHeaderView = [self createTableViewHeadView];
    
}
#pragma mark - 返回
-(void)clickBackBtn{
    [self.navigationController popViewControllerAnimated:YES];
}
@end
